# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=zeek
pkgver=v8.1.0.dev.r1038.g602d899
pkgrel=1
epoch=2
groups=('blackarch' 'blackarch-networking' 'blackarch-defensive'
        'blackarch-sniffer')
pkgdesc='A powerful network analysis framework that is much different from the typical IDS you may know.'
arch=('x86_64' 'aarch64')
url='https://github.com/zeek/zeek'
license=('BSD-3-Clause')
depends=('libpcap' 'openssl-1.0' 'bash' 'python' 'swig' 'ruby' 'perl'
         'crypto++')
makedepends=('git' 'cmake' 'python' 'swig' 'bison' 'flex' 'zlib' 'nodejs'
             'zeromq')
replaces=('bro')
provides=('bro')
source=("git+https://github.com/$pkgname/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  ( set -o pipefail
    git describe --long --tags --abbrev=7 2>/dev/null |
      sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "%s.%s" "$(git rev-list --count HEAD)" \
      "$(git rev-parse --short=7 HEAD)"
  )
}

prepare() {
  cd $pkgname

  git submodule update --init --recursive
}

build() {
  cd $pkgname

  ./configure \
    --prefix=/usr/share/zeek \
    --disable-broker-tests \
    --disable-cpp-tests \

  make
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"

  make DESTDIR="$pkgdir" install

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname" README CHANGES VERSION
  install -Dm 644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  cp -a "$pkgdir/usr/share/$pkgname/bin/"* "$pkgdir/usr/bin/"
  rm -rf "$pkgdir/usr/share/$pkgname/bin"
}

